#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>ans;
const int N = 55, M = 5e5 + 10;
int a[N];
int f[M];
int n, x;
int main()
{
	cin >> n >> x;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum < x) {
		cout << -1 << endl;
		return 0;
	}
    sum -= x;
	for (int i = 1; i <= n; i++) {
		for (int j = sum; j >= a[i]; j--) {
			f[j] = max(f[j], f[j - a[i]] + a[i]);
		}
	}
	//cout << "sum==" << sum << endl;
	//cout << "f[sum]==" << f[sum] << endl;
	cout << x + sum - f[sum] << endl;
	return 0;
}